package cn.com.dcsgo.utils;

import cn.com.dcsgo.model.SecurityUser;
import org.springframework.security.core.context.SecurityContextHolder;

import java.util.Set;

/**
 * 认证工具类
 * 用以获取登录后的用户信息，如权限、用户ID等
 *
 * @author Dcsgo
 * @since 2025/9/22 15:13
 */

public class AuthUtil {
    public static SecurityUser getLoginUser() {
        return (SecurityUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }

    public static Long getUserId() {
        return getLoginUser().getUserId();
    }

    public static String getOpenid() {
        return getLoginUser().getOpenid();
    }


    public static Long getShopId() {
        return getLoginUser().getShopId();
    }

    public static Set<String> getPerms() {
        return getLoginUser().getPerms();
    }
}
